Bring optimised Jaccard code into main#72
Draft
johnlees wants to merge 3 commits into
Draft
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #72 +/- ##
==========================================
- Coverage 91.63% 91.56% -0.07%
==========================================
Files 17 17
Lines 2964 3070 +106
==========================================
+ Hits 2716 2811 +95
- Misses 248 259 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
johnlees
commented
May 18, 2026
Comment on lines
+257
to
+259
| for i in 0..BIN_BITS { | ||
| let orval = Self::bit_at_pos(*sign, i as u64) << leftshift; | ||
| usigs[sign_index / (u64::BITS as usize) * BIN_BITS + i] |= orval; |
Member
Author
There was a problem hiding this comment.
This could probably use chunks_exact
|
|
||
| #[inline(always)] | ||
| fn bin_index(sign: u64, num_bins: u64) -> usize { | ||
| (((sign as u128) * (num_bins as u128)) >> u64::BITS) as usize |
Member
Author
There was a problem hiding this comment.
Seems clever, need to confirm though
| pub fn get_usigs(&mut self) -> Vec<u64> { | ||
| std::mem::take(&mut self.usigs) | ||
| pub fn get_usigs(&mut self) -> SketchVec { | ||
| std::mem::replace(&mut self.usigs, aligned_sketch_vec()) |
| pub const SIGN_MOD: u64 = (1 << 61) - 1; | ||
| pub const BIN_BITS: usize = 16; | ||
| #[doc(hidden)] | ||
| pub const BBITS: usize = BIN_BITS; |
Member
Author
There was a problem hiding this comment.
Should be possible to remove? Might be used in tests
Comment on lines
+127
to
+130
| fn random_match_correction(jaccard: f64) -> f64 { | ||
| let bb = (1u32 << (BIN_BITS as u32)) as f64; | ||
| ((bb * jaccard - 1.0).max(0.0)) / (bb - 1.0) | ||
| } |
Member
Author
There was a problem hiding this comment.
Need to check and confirm
| } | ||
| } | ||
|
|
||
| #[cfg_attr(target_arch = "aarch64", allow(dead_code))] |
Member
Author
There was a problem hiding this comment.
Maybe want these functions inline forced
Comment on lines
+12
to
+13
| //! for information on how to select good lengths. Jaccard distances include random match | ||
| //! correction for the retained sketch signature width. |
Comment on lines
+1
to
+2
| 14412_3#82.contigs_velvet.fa.gz 14412_3#84.contigs_velvet.fa.gz 0.011049058 0.17300157 | ||
| 14412_3#84.contigs_velvet.fa.gz 14412_3#82.contigs_velvet.fa.gz 0.011049058 0.17300157 |
| 14412_3#84.contigs_velvet.fa.gz 5 10 0 0 | ||
| TIGR4.fa.gz 0 0 7 10 | ||
| 14412_3#82.contigs_velvet.fa.gz 10 6 0 0 | ||
| R6.fa.gz 0 0 10 9 |
| Name Sequence length Base frequencies Missing/ambig bases From reads Single strand Densified | ||
| test_1 1 [603, 330, 334, 603] 0 true false true | ||
| test_2 1 [617, 312, 314, 617] 0 true false true | ||
| test_1 91 [603, 330, 334, 603] 0 true false true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #68